<template>
  <div>
    <!-- 新增修改dialog -->
    <Edialog
      title="版本记录"
      :outershow="show"
      @close="closeFn()"
      saveClick
      width="80%"
      @saveFn="addAeditSaveFn"
    >
      <div style="padding: 0 20px">
        <EwangEditor
          ref="editor"
          :html="form.versionRecord"
          @getHtml="getHtml"
          :isClose="true"
        />
      </div>
    </Edialog>
  </div>
</template>

<script>
import Edialog from "@/components/Edialog";
import EwangEditor from "@/components/EwangEditor";
import {
  getVsVersionById,
  postVsVersionDoRecord,
} from "@/api/management/versioning";
import { fd } from "@/utils";
export default {
  name: "patrolPeopleManage",
  components: {
    Edialog,
    EwangEditor,
  },
  data() {
    return {
      // 是否显示弹框
      show: false,
      form: {
        versionRecord: "",
        id: "",
      },
    };
  },
  methods: {
    // 打开弹框方法
    async openFn(scope) {
      this.form.id = scope.id;
      let res = await getVsVersionById(scope.id);
      if (res.data && res.data.bcode == 0) {
        this.form.versionRecord = res.data.bdata.versionRecord;
        this.show = true;
      }
    },
    // 关闭弹框方法 closeLet为true代表保存关闭弹框
    closeFn() {
      this.show = false;
    },
    getHtml(data) {
      console.log("编辑器数据", data);
      if (data && data !== "<p><br></p>") {
        console.log("执行赋值");
        this.form.versionRecord = data;
      }
    },
    // 保存事件
    async addAeditSaveFn() {
      let res = await postVsVersionDoRecord(this.form.id, fd(this.form));
      if (res.data && res.data.bcode == 0) {
        this.$parent.getData();
        this.closeFn();
        this.$message.success(res.data.bmsg);
      }
    },
  },
};
</script>

<style scoped lang="scss"></style>
